package main.java.ensao.cryptography.ui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class GlobalFrame extends JFrame {
	TabbedPane tp = new TabbedPane();
	public GlobalFrame(){
		this.init();
	}
	public void init(){
		this.setSize(1200, 700);
		this.setLocationRelativeTo(null);
		this.setTitle("Cryptography project");
		this.setResizable(true);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		TestImagePanel globalPanel = new TestImagePanel();
		
		globalPanel.setLayout(new BorderLayout());
		tp.setTabPlacement(JTabbedPane.LEFT);
		
		tp.setBorder(BorderFactory.createEmptyBorder(90, 120, 70, 70));
		globalPanel.add(tp,BorderLayout.CENTER);
   
		this.getContentPane().add(globalPanel);
		this.setVisible(true);
		this.setResizable(false);
	}

}


class TestImagePanel extends JPanel {

	private static final long serialVersionUID = 1L;
	 
	private final ImageIcon img = new ImageIcon(
		    getClass().getClassLoader().getResource("ressources/background.png"));
	private Image image = null;
	
	public TestImagePanel() {

		Dimension size = new Dimension(1200,700);
		setPreferredSize(size);
		setMinimumSize(size);
		setMaximumSize(size);
		setSize(size);
		setLayout(null);
	}

	public void paintComponent(Graphics g) {
		image = img.getImage();
		g.drawImage(image, 0, 0, null);
	}

}
